﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
namespace WPFExcelReport
{
    public partial class TAE05
    {

        public TAE05()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VMEVAR();
            this.DataContext = MV;
            InitializeComponent();
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
        }

        public override void OnSave()
        {
            if (!IsSaved)
                return;
            if (dwMaster == null)
                return;
            TMV.UpdateMEVAR(dwMaster, 0);
            string key = KEY;
            KEY = "";
            KEY = key;
            base.OnSave();
        }

        public override void LOADBYAUF()
        {
            TBMain.Clear();
            if (ORDERNUM.Length < 41)
                return;
            dwData = TMV.TBMain.NewRow();
            dwData["MEVMANDANT"] = app.Mandant;
            dwData["MEVAGANG"] = " AND MEVAGANG='" + ORDERNUM.Substring(0, 15) + "'";
            dwData["MEVMTYP"] = " AND MEVMTYP='" + ORDERNUM.Substring(15, 8) + "'";
            dwData["MEVMNRKRS"] = " AND MEVMNRKRS='" + ORDERNUM.Substring(23, 2) + "'";
            dwData["MEVMLFDNR"] = " AND MEVMLFDNR='" + ORDERNUM.Substring(25, 4) + "'";
            dwData["MEVMPOS"] = " AND MEVMPOS='" + ORDERNUM.Substring(29, 2) + "'";
            dwData["MEVEVARHNR"] = " AND MEVEVARHNR='" + ORDERNUM.Substring(31, 2) + "'";
            dwData["MEVEVARUNR"] = " AND MEVEVARUNR='" + ORDERNUM.Substring(33, 2) + "'";
            dwData["MEVMODNR"] = " AND MEVMODNR='" + ORDERNUM.Substring(35, 3) + "'";
            dwData["MEVEINSTNR"] = " AND MEVEINSTNR='" + ORDERNUM.Substring(38, 3) + "'";
            SResult = TMV.QMER02(dwData);
            MergeData(SResult, true);
            base.LOADBYAUF();
        } 
        
    }
}
